package com.cal2sync;

import java.lang.reflect.Method;

import com.android.internal.telephony.ITelephony;

import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.telephony.TelephonyManager;
import android.widget.Toast;

public class TestReceiver extends BroadcastReceiver{

	public void test()
	{
		System.out.println("inside testing method");
	}
	
	@Override
	public void onReceive(Context arg0, Intent arg1) {
		// TODO Auto-generated method stub
		
		try{
			if(GlobalData.flag)
			{
				System.out.println("inside onreceive");
				TelephonyManager manager = (TelephonyManager)arg0.getSystemService(Context.TELEPHONY_SERVICE);
				Class c = Class.forName(manager.getClass().getName());
				Method m = c.getDeclaredMethod("getITelephony");
				m.setAccessible(true);
				ITelephony telephony = (ITelephony)m.invoke(manager);
				telephony.endCall();
			}
		} catch(Exception e){
			e.printStackTrace();
		}
	}
	
}

/*public class Test extends Service{

	@Override
	public IBinder onBind(Intent arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	public static void test(Context context)
	{
		Toast.makeText(context, "Inside service", Toast.LENGTH_LONG).show();

		System.out.println("Service called!!");
	}
	
	@Override
	 public void onStart(Intent intent, int startId) {
	  // TODO Auto-generated method stub
	  super.onStart(intent, startId);
	  Toast.makeText(Test.this, "Inside service", Toast.LENGTH_LONG).show();

		System.out.println("Service called!!");
	}
}*/
